package sentence

import (
	"gin/tai"
	uuid "github.com/satori/go.uuid"
	tccommon "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	nlp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/nlp/v20190408"
	tts "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tts/v20190823"
)

// 情感分析
func SentimentAnalysis(text string) (*nlp.SentimentAnalysisResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewSentimentAnalysisRequest()
	request.Text = tccommon.StringPtr(text)
	var requestModel = "3class"
	request.Mode = &requestModel
	return client.SentimentAnalysis(request)
}

// 关键字分析
func KeywordsExtraction(text *string, number *uint64) (*nlp.KeywordsExtractionResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewKeywordsExtractionRequest()
	request.Text = text
	request.Num = number
	return client.KeywordsExtraction(request)
}

// 文本转语音
func TextToVoice(text string, voiceType int64, codeC string) (*tts.TextToVoiceResponse, error) {
	client, _ := tai.GetTtsClient()
	request := tts.NewTextToVoiceRequest()

	request.Text = tccommon.StringPtr(text)
	request.ModelType = tccommon.Int64Ptr(1)
	request.SessionId = tccommon.StringPtr(uuid.NewV4().String())
	request.Codec = tccommon.StringPtr(codeC)
	request.VoiceType = tccommon.Int64Ptr(voiceType)

	return client.TextToVoice(request)
}
